<template>
  <div style="width:100%;">
    <el-row type="flex" style="width:100%;">
      <el-col :span="18">
        <p class="title">项目信息</p>
        <ul class="ProjectInformation">
          <li>
            <span>申请专利号：</span>
            <a>{{data.apn}}</a>
          </li>
          <li>
            <span>公布号：</span>
            <a>{{data.pn}}</a>
          </li>
          <li>
            <span>发明（设计）人：</span>
            <a>{{data.in | in}}</a>
          </li>
          <li>
            <span>申请（专利权）人：</span>
            <a>{{data.an | in}}</a>
          </li>
          <li>
            <span>专利类型：</span>
            <a>{{data.na}}</a>
          </li>
          <li>
            <span>申请日：</span>
            <a>{{data.apd}}</a>
          </li>
          <li>
            <span>公布日：</span>
            <a>{{data.isd}}</a>
          </li>
        </ul>
      </el-col>
      <el-col :span="6">
        <!-- <div style="width:100%;height:100%;"> -->
        <pie id="pie" :data="data" :J="data.j" style="width:100%;height:100%;"></pie>
        <!-- </div> -->
      </el-col>
    </el-row>
    <el-row type="flex" :gutter="20">
      <el-col :span="8">
        <div class="technology">
          <p>技术纬度</p>
          <div>
            <span></span>
            <i :style="{'width':data.T+'%'}"></i>
          </div>
          <ul>
            <li>
              <i></i>
              <a>有{{data.independent_claims_num}}项独立权力要求</a>
            </li>
            <li>
              <i></i>
              <a>主权项包含标点数：{{data.main_claim_punctuation_count}}个</a>
            </li>
            <li>
              <i></i>
              <a>主权项包含字数：{{data.main_claim_word_count}}个</a>
            </li>

            <li>
              <i></i>
              <a>剩余有效时间：{{data.effective_month}}天</a>
            </li>
            <li>
              <i></i>
              <a>无同族专利：{{data.family_num}}</a>
            </li>
            <li>
              <i></i>
              <a>无引证专利：{{data.citec || 0}}</a>
            </li>

            <li>
              <i></i>
              <a>未被其他专利引证：{{data.refc}}</a>
            </li>

            <li>
              <i></i>
              <a>发明人投入：{{data.innum}}人</a>
            </li>

            <!-- <li>
                            <i></i>
                            <a>正常公开</a>
            </li>-->
          </ul>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="technology">
          <p>法律纬度</p>
          <div>
            <span></span>
            <i class="law" :style="{'width':data.S+'%'}"></i>
          </div>
          <ul>
            <li>
              <i class="law"></i>
              <a>有{{data.dependent_claims_num}}项从属权利要求</a>
            </li>
            <li>
              <i class="law"></i>
              <a>专利类型：{{data.na}}</a>
            </li>
            <!-- <li>
                            <i class="law"></i>
                            <a>包含{{}}页说明说</a>
            </li>-->
            <li>
              <i class="law"></i>
              <a>包含{{data.figure_num}}个附图</a>
            </li>
            <li>
              <i class="law"></i>
              <a>未被无效请求：{{data.legal_wuxiao}}</a>
            </li>
          </ul>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="technology">
          <p>经济纬度</p>
          <div>
            <span></span>
            <i class="Economics" :style="{'width':data.M+'%'}"></i>
          </div>
          <ul>
            <li>
              <i class="Economics"></i>
              <a>未发生过转让：{{data.legal_zhuanyi}}</a>
            </li>
            <li>
              <i class="Economics"></i>
              <a>未发生过许可：{{data.legal_xuke}}</a>
            </li>
            <li>
              <i class="Economics"></i>
              <a>未经历过质押或保全：{{data.legal_zhiya}}</a>
            </li>
            <li>
              <i class="Economics"></i>
              <a>未发生过复审：{{data.legal_fushen}}</a>
            </li>
            <li>
              <i class="Economics"></i>
              <a>未发生过诉讼：{{data.judicature_num}}</a>
            </li>
          </ul>
        </div>
      </el-col>
    </el-row>
    <el-row v-if="show">
      <el-col :span="12">
        <div class="star">
          <div>
            <p>专利质量</p>
            <span>
              <!-- <i v-for="(i,index) in 5" :key="index" class="el-icon-star-on"></i> -->
              <i
                v-for="(index) in Math.ceil(evaluateData[0].details.Q/20)"
                :key="index"
                class="el-icon-star-on"
              ></i>
            </span>
          </div>
          <ul>
            <li>
              <span>特征指数：</span>
              <a>
                {{(evaluateData[0].details.ft < evaluateData[0].patentAssess.ft.superiorData) ? '优' :
                (evaluateData[0].details.ft >= evaluateData[0].patentAssess.ft.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>权项指数：</span>
              <a>
                {{(evaluateData[0].details.rg >= evaluateData[0].patentAssess.rg.superiorData) ? '优' :
                (evaluateData[0].details.rg < evaluateData[0].patentAssess.rg.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>引用情况：</span>
              <a>{{(evaluateData[0].details.ref > evaluateData[0].patentAssess.ref.differenceData) ? '差' : '良'}}</a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>被引用情况：</span>
              <a>{{(evaluateData[0].details.ct >= evaluateData[0].patentAssess.ct.superiorData) ? '优' : '良'}}</a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>稳定性：</span>
              <a>
                {{(evaluateData[0].details.q5 > evaluateData[0].patentAssess.Q5.superiorData) ? '优' :
                (evaluateData[0].details.q5 < evaluateData[0].patentAssess.Q5.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
          </ul>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="star" style="border-right:0;">
          <div>
            <p>技术价值</p>
            <span>
              <!-- <i v-for="(i,index) in 5" :key="index" class="el-icon-star-on" ></i> -->
              <i
                v-for="(index) in Math.ceil(evaluateData[0].details.M/20)"
                :key="index"
                class="el-icon-star-on"
              ></i>
            </span>
          </div>
          <ul>
            <li>
              <span>创新程度：</span>
              <a>
                {{(evaluateData[0].details.inn > evaluateData[0].patentAssess.inn.superiorData) ? '优' :
                (evaluateData[0].details.inn < evaluateData[0].patentAssess.inn.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>技术时效：</span>
              <a>
                {{(evaluateData[0].details.ta < evaluateData[0].patentAssess.ta.superiorData) ? '优' :
                (evaluateData[0].details.ta > evaluateData[0].patentAssess.ta.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>技术宽度：</span>
              <a>
                {{(evaluateData[0].details.tw > evaluateData[0].patentAssess.tw.superiorData) ? '优' :
                (evaluateData[0].details.tw < evaluateData[0].patentAssess.tw.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>技术生命周期：</span>
              <a>
                {{(evaluateData[0].details.tlc > evaluateData[0].patentAssess.tlc.superiorData) ? '优' :
                (evaluateData[0].details.tlc < evaluateData[0].patentAssess.tlc.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
          </ul>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="star">
          <div>
            <p>市场价值</p>
            <span>
              <!-- <i v-for="(i,index) in 5" :key="index" class="el-icon-star-on"></i> -->
              <i
                v-for="(index) in Math.ceil(evaluateData[0].details.T/20)"
                :key="index"
                class="el-icon-star-on"
              ></i>
            </span>
          </div>
          <ul>
            <li>
              <span>研发跟进人数：</span>
              <a>
                {{(evaluateData[0].details.rf > evaluateData[0].patentAssess.rf.superiorData) ? '优' :
                (evaluateData[0].details.rf < evaluateData[0].patentAssess.rf.differenceData) ? '差' : '良'}}
              </a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>转让：</span>
              <a>{{(evaluateData[0].details.tf >= evaluateData[0].patentAssess.tf.superiorData) ? '优' : '一般'}}</a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>许可：</span>
              <a>{{(evaluateData[0].details.lc >= evaluateData[0].patentAssess.lc.superiorData) ? '优' : '一般'}}</a>
              <!-- <a v-else></a> -->
            </li>
          </ul>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="star" style="border-right:0;">
          <div>
            <p>社会影响</p>
            <span>
              <!-- <i v-for="(i,index) in 5" :key="index" class="el-icon-star-on"></i> -->
              <i
                v-for="(index) in Math.ceil(evaluateData[0].details.S/20)"
                :key="index"
                class="el-icon-star-on"
              ></i>
            </span>
          </div>
          <ul>
            <li>
              <span>复审信息：</span>
              <a>{{(evaluateData[0].details.re >= evaluateData[0].patentAssess.re.superiorData) ? '优' : '一般'}}</a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>无效信息：</span>
              <a>{{(evaluateData[0].details.ivd >= evaluateData[0].patentAssess.ivd.superiorData) ? '优' : '一般'}}</a>
              <!-- <a v-else></a> -->
            </li>
            <li>
              <span>诉讼纠纷：</span>
              <a>{{(evaluateData[0].details.suitCount > 0) ? '优' : '一般'}}</a>
              <!-- <a v-else></a> -->
            </li>
          </ul>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import pie from "./child/pie2";
import axios from "axios";
let jwt = require('jsonwebtoken')
export default {
  data() {
    return {
      data: {},
      evaluateData: [],
      pn: "",
      show: false,
      user: ''
    };
  },
  filters: {
    in(val) {
      if (val) {
        let str = "";
        val.forEach(i => {
          str += i + ",";
        });
        return (str = str.substring(0, str.length - 1));
      }
    }
  },
  components: {
    pie
  },
  methods: {
    init() {
      this.pn = this.$route.query.pn;
      let pn = this.pn;
      this.evaluateData.push({ pn: pn });
      this.$get(this.$Url.finance.Get_patent_features, {
        pn,
        user: this.user
      }).then(res => {
        if (res.data) {
          res.data.j = String(res.data.j);
          this.data = res.data;
        }
      }).catch(e => {
        console.log(e);
      })

      axios.all([this.a(), this.b(), this.c()]).then(
        axios.spread((res1, res2, res3) => {
          if (
            this.evaluateData[0].details &&
            this.evaluateData[0].patentAssess
          ) {
            this.show = true;
          }
        })
      );
    },
    a() {
      return this.$get(this.$Url.finance.pantentScoreInfo, {
        pn: this.pn
      })
        .then(res => {
          let data = res.data;
          for (let i in this.evaluateData) {
            if (this.evaluateData[i].pn === this.pn) {
              let details = {
                Q: data.q, // 专利质量
                T: data.t, // 市场价值
                M: data.m, // 技术价值
                S: data.s, // 社会影响
                //
                q5: data.q5, // 稳定性
                ref: data.ref, // 引用数
                ct: data.ct, // 被引用
                ft: data.ft, // 特征度
                rg: data.rg, // 权项数

                inn: data.inn, // 创新程度
                ta: data.ta, // 技术时效
                tw: data.tw, // 技术宽度
                tlc: data.tlc, // 技术生命周期

                rf: data.rf, // 研发跟进人数
                tf: data.tf, // 转让
                lc: data.lc, // 许可
                re: data.re, // 复审信息
                ivd: data.ivd // 无效信息
              };
              this.$set(this.evaluateData[i], "details", details);
              break;
            }
          }
        })
        .catch(e => {
          console.log(e);
        });
    },
    b() {
      // 获取专利指标优、差、平均值
      return this.$get(this.$Url.finance.patentAssess)
        .then(res => {
          let data = res.data;
          let obj = {};
          for (let i in data) {
            obj[data[i].type] = data[i];
          }
          for (let i in this.evaluateData) {
            if (this.evaluateData[i].pn === this.pn) {
              this.$set(this.evaluateData[i], "patentAssess", obj);
              break;
            }
          }
        })
        .catch(e => {
          console.log(e);
        });
    },
    c() {
      // 诉讼纠纷
      return this.$get(this.$Url.finance.suitCount, {
        pn: this.pn
      })
        .then(data => {
          if (data) {
            for (let i in this.evaluateData) {
              if (this.evaluateData[i].pn === this.pn) {
                this.$set(
                  this.evaluateData[i]["details"],
                  "suitCount",
                  data.data
                );
              }
            }
          }
        })
        .catch(err => {});
    }
  },
  created() {
    let token = this.$cookie.get("token")
    this.user = jwt.decode(token).sub
    this.init();
  },
};
</script>
<style lang="scss" scoped>
.title {
  line-height: 60px;
  font-size: 14px;
  font-weight: bold;
  color: #505058;
}
.ProjectInformation {
  width: 100%;
  border: 1px solid #e7e5ea;
  li {
    width: 50%;
    display: inline-block;
    line-height: 50px;
    border-bottom: 1px solid #e7e5ea;
    span,
    a {
      display: inline-block;
    }
    span {
      width: 30%;
      background: #f2f6f9;
      padding-left: 20px;
      font-weight: bold;
    }
    a {
      width: 70%;
      padding-left: 20px;
    }
    &:last-child {
      border-bottom: none;
    }
  }
}
.el-row {
  margin-bottom: 40px;
}
.technology {
  width: 100%;
  border: 1px solid #ddd;
  padding: 20px;
  height: 100%;
  background: #fbfcff;
  p {
    line-height: 30px;
    padding-bottom: 10px;
    font-weight: bold;
  }
  div {
    width: 90%;
    position: relative;
    span {
      display: block;
      position: absolute;
      width: 100%;
      height: 5px;
      border-radius: 3px;
      background: #e4e6f2;
    }
    i {
      display: block;
      position: absolute;
      top: -1px;
      left: 0;
      background: #2688cf;
      height: 7px;
      border-radius: 4px;
    }
  }
  ul {
    padding-top: 30px;
    width: 100%;
    li {
      width: 100%;
      line-height: 30px;
      i {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: #2688cf;
      }
      a {
        display: inline-block;
        padding-left: 15px;
      }
    }
  }
  .law {
    background: #4dd2bf;
  }
  .Economics {
    background: #ff8b66;
  }
}
.star {
  border-bottom: 1px solid #ddd;
  border-right: 1px solid #ddd;
  padding-left: 30px;
  padding-top: 20px;
  width: 100%;
  > div {
    width: 100%;
    padding-bottom: 20px;
    p,
    span {
      display: inline-block;
    }
    span {
      padding-left: 20px;
      i {
        padding: 0 5px;
        font-size: 18px;
        color: #b5bbdb;
      }
    }
    p {
      font-weight: bold;
      font-size: 14px;
    }
  }
  > ul {
    width: 100%;
    overflow: hidden;
    padding-bottom: 20px;
    li {
      width: 30%;
      float: left;
      span,
      a {
        display: inline-block;
        line-height: 30px;
      }
      span {
        width: 150px;
      }
      a {
        color: #504ba5;
        font-weight: bold;
      }
    }
  }
}
</style>